package com.doudou.casebook;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.doudou.casebook.db.DBManager;

public class SettingActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
    }

    public void onClick(View v){
        if(v.getId()==R.id.setting_iv_back){
            finish();
        }
        if (v.getId()==R.id.setting_tv_delete_all){
            new AlertDialog.Builder(this).setTitle("提示信息").setMessage("你确认要删除所有数据吗？ \n删除后不可恢复，请谨慎操作！ ")
                    .setNegativeButton("取消",null)
                    .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                           DBManager.deleteAllAccounttb();
                            Toast.makeText(SettingActivity.this, "删除成功!", Toast.LENGTH_SHORT).show();
                        }
                    }).create().show();
        }
    }
}